#ifndef TRANSFORMATIONS_CPP
#define TRANSFORMATIONS_CPP

#include "Transformations.h"
#include <QDebug>

QList<int> * Transformations::getNeighboringPixels (QImage * img, int pixel)
{
    QList<int> * neighbors = new QList<int>;

    // Obtain the pixel coordinates
    int x = getX(img, pixel);
    int y = getY(img, pixel);

    // For each pixel in the same row that the center's one...
    for (int i = x - 1; i <= x + 1; i++ )
        for (int j = y -1; j <= y + 1; j++)
        {
            // If it is not the center pixel
            if (getPixelNumber(img, i, j) != pixel)

                // Checking if the pixel is included into the Image...
                if (img->rect().contains( i, j))
                    neighbors->push_back( getPixelNumber(img, i, j) );
        }

    return neighbors;
}

int Transformations::getIntensity(QImage * img, int pixel)
{
    return getIntensity(img, getX(img, pixel), getY(img, pixel));
}

int Transformations::getIntensity(QImage * img, int x, int y)
{
    QColor color( img->pixel(x, y) );
    return color.red();
}


#endif // TRANSFORMATIONS_CPP
